import healthtrends

# lazy fix for utf-8 encoding for accents and complex characters in term list
import sys
reload(sys)
sys.setdefaultencoding("utf-8")

# start session
gt = healthtrends.TrendsSession(api_key="AIzaSyAsNpCmioFdNmuGrNyKl7HaTs318UOVL0I")

# download from all needed states
state_ids = ["BR-SE", "BR-RJ", "BR-SP", "BR-MG", "BR-BA", "BR-RO", "BR-CE", "BR-AM", "BR-PI", "BR-MT", "BR-PE", "BR-MA", "BR-MS"]
queries = ["Mosquito", "Mosquitos"]

for state_id in state_ids:
	gt.request_trends(term_list=queries, geo_level='region', geo_id = state_id)
	filename = state_id + "_mosquito_trends.csv"
	gt.save_to_csv(directory='/Users/galkoplewitz/Desktop/Summer Research/Epidemiology/GT data', fname = filename)